import { GET_INIT_LIST, CHANGE_INPUT_VALUE, ADD_TODO_ITEM, DELETE_TODO_ITEM, INIT_TODO_LIST } from './actionTypes';

export const getInputChangeAction = (value) => ({
	type: CHANGE_INPUT_VALUE,
	value
});

export const getAddItemAction = () => ({
	type: ADD_TODO_ITEM
});

export const getDeleteItemAction = (index) => ({
	type: DELETE_TODO_ITEM,
	index
});

export const initTodoList = (data) => ({
	type: INIT_TODO_LIST,
	data
});

// 使用redux-thunk的代码
// export const getTodoList = () => {
// 	return (dispatch) => {
// 		axios.get('/mocker/test.json').then((res) => {
// 			const data = res.data.list;
// 			const action = initTodoList(data);
// 			dispatch(action);
// 		})
// 	}
// };

// redux-saga
export const getInitList = () => ({
	type: GET_INIT_LIST
})

